/** @file main.c 
 * Das Main File mit einem Testprogramm zum Testen der verschiedenen LCV Framework Funktionen
 * 
 * @author Daniel Kummer, Sebastian Kummer
 * @date Donnerstag, Dezember 12, 2007
 * @version 1.0
 */

#include <stdio.h>
#include "main.h"
#include "config.h"
#include "test-bmp.h"
#include "test-cam.h"
#include "test-dip.h"
#include "test-gpio.h" 	
#include "test-log.h"



int main() 
{	
	printf("STARTING TEST PROGRAMM\n");
	
	printf("\nLOG-MODULE:\n");
	test_log();
	
	//printf("\nBMP-MODULE:\n");
	//test_bmp();	
	
	printf("\nGPIO-MODULE:\n");
	test_gpio();
	
	printf("\nCAM-MODULE:\n");	
	test_cam();
	
	printf("\nDIP-MODULE:\n");
	test_dip();
	
	printf("\nHTML-VIEW:\n");
	html_view();
	
	printf("\nTEST COMPLETED\n");
			
	return 0;
}

void html_view()
{
	printf("writing html file... ");
	fflush(stdout);
	
	char filename[sizeof(FOLDER_PREFIX) + 20];
	sprintf (filename, "%sfw.html", FOLDER_PREFIX);	
	
	FILE* htmlfile = fopen(filename, "w+");
	fprintf(htmlfile, "<html>\n");
	fprintf(htmlfile, "<head>\n");
	fprintf(htmlfile, "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n");	
	fprintf(htmlfile, "<title>LCV Framework</title>\n");
	fprintf(htmlfile, "</head>\n");
	fprintf(htmlfile, "<body bgcolor=\"#ececec\">\n");
	
	fprintf(htmlfile, "<h1>LCV Framework</h1>\n");
	
	fprintf(htmlfile, "<h2>Test Bilder</h2>\n");
	
	fprintf(htmlfile, "<img border=\"0\" src=\"dip_capture_frame.bmp\" /><br />\n");
	fprintf(htmlfile, "Unbearbeitetes Bild<br /><br />\n");
	
	fprintf(htmlfile, "<img border=\"0\" src=\"dip_inverted.bmp\" /><br />\n");
	fprintf(htmlfile, "Invertiertes Bild<br /><br />\n");
	
	fprintf(htmlfile, "<img border=\"0\" src=\"dip_reversed.bmp\" /><br />\n");
	fprintf(htmlfile, "Gedrehtes Bild<br /><br />\n");
	
	fprintf(htmlfile, "<img border=\"0\" src=\"dip_gray.bmp\" /><br />\n");
	fprintf(htmlfile, "Graustufenbild<br /><br />\n");
	
	fprintf(htmlfile, "</body>\n");
	fprintf(htmlfile, "</html>\n");
	fclose(htmlfile);
	
	
	printf("ok\n");	
	
}

